import EventBus from "../EventBus"
import store from "@/store"
function getLowCode() {
  return store.state.lowCode
}
const listConfig = {
  prev: {
    name: "上一步",
    type: "prev",
    icon: "swap-left",
    disabled: () => getLowCode().snapshotIndex === getLowCode().snapshotMinIndex,
    onClick: (vueObj)=> {
      EventBus.$emit("snapshotPrev")
    }
  },
  next: {
    name: "下一步",
    type: "next",
    icon: "swap-left",
    disabled: () => getLowCode().snapshotList.length === getLowCode().snapshotIndex + 1,
    onClick: ()=> {
      EventBus.$emit("snapshotNext")
    }
  },
  deleteAll: {
    name: "清空画布",
    type: "deleteAll",
    icon: "deleteAll",
    // disabled: () => !(getLowCode().snapshotIndex > getLowCode().snapshotMinIndex && getLowCode().snapshotList[getLowCode().snapshotIndex].length > 0),
    disabled: () => getLowCode().canvasComponentList.length === 0,
    onClick: ()=> {
      EventBus.$emit("deleteAll")
    }
  },
  reset: {
    name: "重置画布",
    type: "reset",
    icon: "reset",
    disabled: () => getLowCode().snapshotList.length === 0,
    onClick: ()=> {
      EventBus.$emit("reset")
    }
  },
  delete: {
    name: "删除",
    type: "delete",
    icon: "delete",
    disabled: () => getLowCode().multipleKeys.length === 0,
    onClick: ()=> {
      EventBus.$emit("delectSelectedComponent")
    }
  },
  topping: {
    name: "置顶",
    type: "topping",
    icon: "topping",
    disabled: () => !getLowCode().selectedComponent.key,
    onClick: ()=> {
      EventBus.$emit("toppingSelectedComponent")
    }
  },
  setAtEnd: {
    name: "置底",
    type: "setAtEnd",
    icon: "setAtEnd",
    disabled: () => !getLowCode().selectedComponent.key,
    onClick: ()=> {
      EventBus.$emit("setAtEndSelectedComponent")
    }
  },
  cancel: {
    name: "取消",
    type: "cancel",
    icon: "cancel",
    disabled: () => false,
    onClick: ()=> {
      EventBus.$emit("cancelSelectedComponent")
    }
  },
  save: {
    name: "保存",
    type: "save",
    icon: "save",
    disabled: () => getLowCode().snapshotList.length === 0,
    onClick: ()=> {
      EventBus.$emit("save")
    }
  },
  saveAs: {
    name: "另存为",
    type: "saveAs",
    icon: "save",
    disabled: () => getLowCode().snapshotList.length === 0,
    onClick: ()=> {
      EventBus.$emit("saveAs")
    }
  },
  preview: {
    name: "预览",
    type: "preview",
    icon: "preview",
    disabled: () => false,//getLowCode().previewData.componentList.length === 0,
    onClick: ()=> {
      EventBus.$emit("preview")
    }
  },
  copy: {
    name: "复制",
    type: "copy",
    icon: "copy",
    disabled: () => getLowCode().multipleKeys.length === 0,
    onClick: ()=> {
      EventBus.$emit("copy")
    }
  },
  paste: {
    name: "粘贴",
    type: "paste",
    icon: "paste",
    disabled: () => getLowCode().clipboardData.length === 0,
    onClick: ()=> {
      EventBus.$emit("paste")
    }
  },
  shear: {
    name: "剪切",
    type: "shear",
    icon: "shear",
    disabled: () => getLowCode().multipleKeys.length === 0,
    onClick: ()=> {
      EventBus.$emit("shear")
    }
  },
  dataDetails: {
    name: "数据明细",
    type: "dataDetails",
    icon: "shear",
    disabled: () => getLowCode().multipleKeys.length === 0,
    onClick: ()=> {
      EventBus.$emit("dataDetails")
    }
  }
  
}



export default function getButnList(typeList= []){
  return typeList.map(item => listConfig[item])
}

